<template>
	<view class="page flex-col">

		<view class="group_2 flex-col">

			<view class="box_2 flex-col">
				<view class="group_3 bgb  flex-row justify-between">
					<view class="image-text_1 flex-row justify-between">
						<text class='iconfont icon-sousuo2'></text>
						<!-- :borderColor="#fff" -->
						<uni-easyinput type="text" @clear="change" :inputBorder="false" placeholder="输入您想搜索的医生名字"
							v-model="doctorName" />
					</view>
					<view class="text-wrapper_1 bb flex-col" @click="init()">
						<text class="text_6">搜索</text>
					</view>
				</view>
			</view>
			<view class="index-coupon" v-if="isInput">
				<scroll-view scroll-x="true" class="index-coupon-view">
					<view class="index-coupon-msg" v-for="(item,index ) in headList" :key="index">
						<view class="index-coupon-msg-msg" :class="activeTabIndex==index?'activeTab':''"
							@click="manuBtn(index,item.id)">
							{{item.name}}
						</view>
					</view>
				</scroll-view>

			</view>

		</view>
		<view class="" v-if="list.length!=0">
			<view class="group_4 flex-col" v-for="(item,index) in list" :key="index">
				<view class="section_2 flex-row justify-between">
					<view class="box_4 flex-col">
						<image :src="item.image" mode=""></image>
					</view>
					<view class="box_5 flex-col">
						<view class="text-wrapper_3 flex-row ">
							<text class="text_13">{{item.name}}</text>
							<text class="text_14">{{item.title}}</text>
							<text class="text_14">{{item.category}}</text>
						</view>
						<view class="block_2 flex-row ">
							<view class="text-wrapper_4 bgb flex-col" v-for="(items,index) in item.hospitalTag"
								:key="index">
								<text class="text_16 bc">{{items}}</text>
							</view>
							<view class="text_17">{{item.hospitalName}}</view>
						</view>
						<view class="block_3 flex-row ">
							<view class="text-wrapper_5 flex-col" v-for="(tag,index) in item.tag" :key="index">
								<text class="text_18">{{tag}}</text>
							</view>

						</view>
					</view>
				</view>
				<view class="text_20">
					擅长：{{item.doctorDesc}}
				</view>
				<view class="text-wrapper_7 bb flex-col" @click="goPage('/pagesA/hospital/doctorInfo?id='+item.id)">
					<text class="text_21">立即挂号</text>
				</view>
			</view>

		</view>
		<view class="" v-else>
			<noData></noData>
		</view>
<home></home>
	</view>
</template>
<script>
	import home from '@/components/home/index.vue'
	import noData from '@/components/com/noData.vue'
	import {
		searchDoctor,
		getCategory
	} from '@/api/togeterRich/family.js'
	export default {
		components: {
			noData,
			home
		},
		data() {
			return {
				isInput: true,
				activeTabIndex: 0,
				constants: {},
				headList: [],
				cid: '',
				isHot: '',
				doctorName: '',
				list: []
			};
		},
		onLoad(e) {
			this.isHot = e.isHot
			// console.log(this.isHot, 'isHotisHot')
			this.headInit()

		},
		methods: {
			change(e) {
				console.log(e, 'ddd')
				// this.doctorName = ''

				this.init()

			},
			headInit() {
				getCategory().then(ree => {
					this.headList = ree.data
					this.cid = this.headList[0].id
					this.isHot = true
					this.init()
				})

			},
			init() {
				let data = {
					name: this.doctorName,
					cid: this.cid,
					isHot: this.isHot
				}
				console.log(data, 'datadata')
				searchDoctor(data).then(res => {
					this.list = res.data

					// console.log(res, '应该是所有医生')
				})
				if (this.doctorName != '') {
					this.isInput = false
				} else {
					this.isInput = true
				}
			},
			goPage(url) {
				uni.navigateTo({
					url
				})
			},
			manuBtn(index, id) {
				this.activeTabIndex = index
				if (this.activeTabIndex == 0) {
					this.isHot = true
				} else {
					this.isHot = false
				}

				this.cid = id
				this.init()
			}
		},
	};
</script>
<style lang="scss" scoped>
	@import 'com/css/doctorList.css';
	@import '@/com/css/common.css';

.bc{
			color: $maincolor !important;
		}
		.bgb{
			border: 2rpx solid $maincolor !important;
		}
		.bb{
			background: $maincolor;
		}

	.activeTab {
		border-bottom: 4rpx solid $maincolor;
		color: $maincolor;
	}

	.index-coupon {

		width: 100%;
		padding: 13px 20rpx;
		border-radius: 10rpx;

		background: #fff;
		display: flex;
		justify-content: space-between;
		align-items: baseline;


		.index-coupon-view {
			white-space: nowrap;
			padding: 15rpx 0;
			margin: 0 auto;

			.index-coupon-msg {
				.index-coupon-msg-msg {
					color: $maincolor;
					padding: 8rpx 20rpx;
					color: #000;

				}

				display: inline-block;
				opacity: 1;
				margin-right: 50rpx;
			}
		}


	}
</style>